#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include "topology.h"
#include "labyrinth.h"
#include "EasyBMP.h"

int main(int argc, char *argv[])
{
    struct topology *my_top;
    int** my_lab;
    int i, j;
    int size, time0, time1;
    
    BMP Output;
    RGBApixel PB, PW ,NewPixel;
    
    srand( time(0) );
    
    time0 = time(0);
    
    my_top = generate_topology(9);
    my_lab = convert_topology(my_top, 0);
    
    size = 0;
    for(i  = 0; i < my_top->depth + 1; i++)
        size = size * 2 + 1;
    
    Output.SetSize(size * 2, size * 2);
    PB.Red = 0;
    PB.Blue = 0;
    PB.Green = 0;
    PB.Alpha = 0;
    PW.Red = 0xFF;
    PW.Blue = 0xFF;
    PW.Green = 0xFF;
    PW.Alpha = 0xFF;
    Output.SetBitDepth( 24 );
    
    for(i = 0; i < size; i++)
        for(j = 0; j < size; j++) {
            if(my_lab[i][j])
                NewPixel = PW;
            else NewPixel = PB;
            Output.SetPixel(2 * i, 2 * j, NewPixel);
            Output.SetPixel(2 * i + 1, 2 * j, NewPixel);
            Output.SetPixel(2 * i, 2 * j + 1, NewPixel);
            Output.SetPixel(2 * i + 1, 2 * j + 1, NewPixel);
        }
    
    Output.WriteToFile("result.bmp");
    
    time1 = time(0);
    
    printf("TIME: %d %d\n", time1, time0);
    
    system("PAUSE");
    return 0;
}
